package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.RightsMapper;
import com.jt.pojo.Rights;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RightServiceImpl implements RightService {
    @Autowired
    private RightsMapper rightsMapper;
    @Override
    public List<Rights> findAll() {
        QueryWrapper <Rights> qw=new QueryWrapper<>();
        qw.eq("parent_id",0);
        List<Rights> list=rightsMapper.selectList(qw);
        for (int i=0;i<list.size();i++){
            Integer id = list.get(i).getId();
            QueryWrapper qw2=new QueryWrapper();
            qw2.eq("parent_id",id);
            list.get(i).setChildren(rightsMapper.selectList(qw2));

        }
        return list;




    }

}
